package com.szgr.baoyin.myview;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by rjp on 15/12/7.
 */
public class TiView extends View {

    private Paint mPaint;

    public TiView(Context context) {
        super(context,null);
    }

    public TiView(Context context, AttributeSet attrs) {
        super(context, attrs,0);
    }

    public TiView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        mPaint = new Paint();

    }

    @Override
    protected void onDraw(Canvas canvas) {
//        super.onDraw(canvas);
        mPaint = new Paint();
        mPaint.setColor(Color.YELLOW);

        for (int i = 0; i <300; i++) {
            canvas.drawLine(50-(i*1.0f/6), 0 + 0.5f * i, 150-(i*1.0f/6), 0+ 0.5f * i, mPaint);
        }
        mPaint.setTextSize(30);
        mPaint.setColor(Color.WHITE);
        canvas.drawText("12", 50, 75, mPaint);

        mPaint.setColor(Color.GREEN);
        for (int i = 0; i <300; i++) {
            canvas.drawLine(150-(i*1.0f/6), 0 + 0.5f * i, 250-(i*1.0f/6), 0+ 0.5f * i, mPaint);
        }
        mPaint.setColor(Color.WHITE);
        canvas.drawText("13", 150, 75, mPaint);

        mPaint.setColor(Color.BLACK);
        for (int i = 0; i <300; i++) {
            canvas.drawLine(250-(i*1.0f/6), 0 + 0.5f * i, 350-(i*1.0f/6), 0+ 0.5f * i, mPaint);
        }
        mPaint.setColor(Color.WHITE);
        canvas.drawText("14", 250, 75, mPaint);

        mPaint.setColor(Color.RED);
        for (int i = 0; i <300; i++) {
            canvas.drawLine(350-(i*1.0f/6), 0 + 0.5f * i, 1000-(i*1.0f/6), 0+ 0.5f * i, mPaint);
        }


        mPaint.setColor(Color.WHITE);
        canvas.drawText("15", 550, 75, mPaint);
    }
}
